package com.jh.paymentchannel.service;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jh.paymentchannel.business.TopupPayChannelBusiness;
import com.jh.paymentchannel.util.Util;

@Controller
@EnableAutoConfiguration
public class JFInfoPage {
	 
	private static final Logger LOG = LoggerFactory.getLogger(JFInfoPage.class);
	
	@Autowired
	private TopupPayChannelBusiness topupPayChannelBusiness;
	
	@Autowired
	private Util util;
	
	
	
	@RequestMapping(method=RequestMethod.GET,value="/v1.0/paymentchannel/topup/tojfbankinfo")
	public  String tojfbankinfo(HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		String bankName = request.getParameter("bankName");//结算卡银行名称
		String bankNo = request.getParameter("bankNo");//结算卡卡号
		String amount = request.getParameter("amount");
		String ordercode = request.getParameter("ordercode");
		String provinceOfBank = request.getParameter("provinceOfBank");
		String cityOfBank = request.getParameter("cityOfBank");
		String bankBranchName = request.getParameter("bankBranchName");
		String bankBranchId = request.getParameter("bankBranchId");
		String cardType = request.getParameter("cardType");
		String isRegister = request.getParameter("isRegister");

		
		model.addAttribute("bankName", bankName);
		model.addAttribute("bankNo",bankNo);
		model.addAttribute("amount", amount);
		model.addAttribute("ordercode", ordercode);
		model.addAttribute("provinceOfBank", provinceOfBank);
		model.addAttribute("cityOfBank", cityOfBank);
		model.addAttribute("bankBranchName", bankBranchName);
		model.addAttribute("bankBranchId", bankBranchId);
		model.addAttribute("cardType", cardType);
		model.addAttribute("isRegister", isRegister);
		
		return "jfbankInfo";
	}
	
	
	@RequestMapping(method=RequestMethod.GET,value="/v1.0/paymentchannel/topup/jfpaysuccess")
	public  void returnpaysuccess(HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
		// 设置编码
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		
		String pageContent = request.getParameter("pageContent");
		LOG.info("我是传过来的&&&pageContent====="+pageContent);
		PrintWriter out = response.getWriter();
		
		out.print(pageContent);
		
		out.close();
	}
	
	
	@RequestMapping(method=RequestMethod.GET,value="/v1.0/paymentchannel/topup/jfpayerror")
	public  String returnpayerror(HttpServletRequest request, HttpServletResponse response, Model model)throws IOException {
		// 设置编码
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
	
		return "sdjerror";
	}
	
}
	
